package cn.kgc.tangcco.utils.qiniuyun;

import com.qiniu.storage.Region;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author 李昊哲
 * @Description
 * @create 2020/9/6 下午3:57
 */

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class QiniuyunUpload {
    /**
     * 访问秘钥
     */
    private String accessKey;
    /**
     * 加密秘钥
     */
    private String secretKey;
    /**
     * 访空间名称
     */
    private String bucket;
    /**
     * 上传文件名
     */
    private String key;
    /**
     * 上传授权
     */
    private String token;

    /**
     * 区域
     */
    private Region region;

    public QiniuyunUpload(String accessKey, String secretKey, String bucket) {
        this.accessKey = accessKey;
        this.secretKey = secretKey;
        this.bucket = bucket;
        Auth auth = Auth.create(accessKey, secretKey);
        this.token = auth.uploadToken(bucket);
//        StringMap putPolicy = new StringMap();
//        long expireSeconds = 3600;
        // 上传凭证
//        this.token = auth.uploadToken(bucket, accessKey, expireSeconds, putPolicy);
    }
}
